/**
 * Created by zhoushg on 2017/9/29.
 */
import getData from './funcs/getData'
import {isEmptyObject, isEmptyStr, isRange} from './funcs/required'
import {toast} from '../utils/gui_main'
import { getToken } from '../utils/auth'
 // addCode
			// r1KGaJFDH Start
			
        export function ADarticle (data) { // article-新增
            var data = data
            return new Promise(resolve => {
            
            let data2 = {
              
            title: data.title, // 标题
            info: data.info, // 简介
            content: data.content, // 内容
            auth: data.auth, // 作者
            level: data.level // 等级
            }
            data = data2
            data.token = getToken()
              function callBack (data) {
                resolve(data)
              }
              getData({
                url: '/article/add',
                method: 'post',
                data
              }, callBack)
            })
          }
        
			// r1KGaJFDH end
			
			// Bk9VXVvvH Start
			
        export function GTOarticle (params) { // article-查询
            var data = params
            return new Promise(resolve => {
            
            let data2 = {
              
            }
            params = data2
            params.token = getToken()
              function callBack (data) {
                resolve(data)
              }
              getData({
                url: '/article/data',
                method: 'get',
                params
              }, callBack)
            })
          }
        
			// Bk9VXVvvH end
			
			// HJwEQEvwS Start
			
        export function ADarticle (data) { // article-新增
            var data = data
            return new Promise(resolve => {
            
            let data2 = {
              
            title: data.title, // 标题
            info: data.info, // 简介
            content: data.content, // 内容
            auth: data.auth, // 作者
            level: data.level // 推荐等级
            }
            data = data2
            data.token = getToken()
              function callBack (data) {
                resolve(data)
              }
              getData({
                url: '/article/add',
                method: 'post',
                data
              }, callBack)
            })
          }
        
			// HJwEQEvwS end
			
			// rJ24QNwwr Start
			
        export function DLTarticle (data) { // article-删除
            var data = data
            return new Promise(resolve => {
            
        if (isEmptyStr(data._id)) {
          toast.warn('数据唯一id不能为空')
          resolve(false)
          return
        }
            let data2 = {
              
            _id: data._id // 数据唯一id
            }
            data = data2
            data.token = getToken()
              function callBack (data) {
                resolve(data)
              }
              getData({
                url: '/article/delete',
                method: 'post',
                data
              }, callBack)
            })
          }
        
			// rJ24QNwwr end
			
			// S1o4QVvwr Start
			
        export function WEarticle (params) { // article-分页查询
            var data = params
            return new Promise(resolve => {
            
            let data2 = {
              
            start: data.start, // 分页起始位置
            limit: data.limit // 分页显示条数
            }
            params = data2
            params.token = getToken()
              function callBack (data) {
                resolve(data)
              }
              getData({
                url: '/article/list',
                method: 'get',
                params
              }, callBack)
            })
          }
        
			// S1o4QVvwr end
			
			// ryO47EPDH Start
			
        export function UDTarticle (data) { // article-修改
            var data = data
            return new Promise(resolve => {
            
        if (isEmptyStr(data._id)) {
          toast.warn('列表唯一id不能为空')
          resolve(false)
          return
        }
            let data2 = {
              
            _id: data._id, // 列表唯一id
            title: data.title, // 标题
            info: data.info, // 简介
            content: data.content, // 内容
            auth: data.auth, // 作者
            level: data.level // 推荐等级
            }
            data = data2
            data.token = getToken()
              function callBack (data) {
                resolve(data)
              }
              getData({
                url: '/article/update',
                method: 'post',
                data
              }, callBack)
            })
          }
        
			// ryO47EPDH end
			